package com.common.filter;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

public class IpFilter extends FilterAdapter {

	@Override
	public void init(javax.servlet.FilterConfig filterConfig) throws ServletException {
		System.out.println("ip filter");
	};
	
	@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
		
		String ip = request.getRemoteAddr();  //得到客户端的ip
		
		System.out.println("Client ip:" + ip);
		
	//	LoginRecordService LoginRecordService = new LoginRecordServiceImpl();
		
		
		Map<String ,Object> params = new HashMap<String,Object>();
		params.put("", ip);
		//params.put("", ip);
	//	LoginRecordService.findByParams(params);
		
		//每天每个Ip登陆记录超过100次，当日拒绝登陆
		
		// chain.doFilter(request, response);
		
	}
	
	@Override
	public void destroy() {
		
	}
}
